<template>
	<u-modal
		v-model="show"
		:show-cancel-button="true"
		:confirm-text="$t('locales.upgrade')"
		:cancel-text="$t('locales.cancel')"
		:title="$t('locales.newVersion')"
		@cancel="cancel"
		@confirm="confirm"
	>
		<view class="u-update-content">
			<rich-text :nodes="rowData.updateContent"></rich-text>
		</view>
	</u-modal>
</template>

<script>
export default {
	data() {
		return {
			show: true,
			rowData: {}
		}
	},
	onLoad(opt) {
		this.rowData = JSON.parse(opt.data)
	},
	onReady() {
	},
	methods: {
		// 取消事件
		cancel() {
			if (this.rowData.enforcement === 1) { // 强制更新
				switch (uni.getSystemInfoSync().platform) {
					case 'android':
						plus.runtime.quit()
						break
					case 'ios':
						const threadClass = plus.ios.importClass('NSThread')
						const mainThread = plus.ios.invoke(
							threadClass,
							'mainThread'
						)
						// plus.ios.invoke(mainThread, 'exit')
						//上面的不行就用下面的
						plus.ios.import("UIApplication").sharedApplication().performSelector("exit")
						break
				}
			} else {
				uni.reLaunch({
					url: 'pages/index/home/index'
				})
			}
		},
		// 确认事件
		confirm() {
			
		}
	}
}
</script>

<style scoped lang="scss">
.u-full-content {
	background-color: #00c777;
}

.u-update-content {
	font-size: 26rpx;
	color: $u-content-color;
	line-height: 1.7;
	padding: 30rpx;
}
</style>
